package com.nuit.cxl.mvcdemo.controller;

import com.nuit.cxl.mvcdemo.dao.Person;
import com.nuit.cxl.mvcdemo.dao.Teacher;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

@Controller
public class BiliController {

    @RequestMapping("/biliview")
    public String getBili(String view, Model model){
        //这里返回的就是 view ，bili.html  这个文件
        model.addAttribute("name",view);
        return "bili";
    }

    @RequestMapping("/bili")
    @ResponseBody
    public Person getBili2(){
        //去数据库里面查询数据
        //把他放在里面
        ArrayList<String> address = new ArrayList<>();
        address.add("guangdongd");
        address.add("foshan");
        Teacher teacher = new Teacher();
        teacher.setName("teacher");
        Person person = new Person("zhanshang", 10, address, teacher);

        return person;
    }
}
